//
//  YindaoViewController.m
//  LiangYa_BObject
//
//  Created by dllo on 15/11/6.
//  Copyright © 2015年 YuHao. All rights reserved.
//

#import "YindaoViewController.h"

@interface YindaoViewController ()<UIScrollViewDelegate>
@property (nonatomic ,strong) UIScrollView *scrollView;
@property (nonatomic ,strong) UIPageControl *pageControl;
@end

@implementation YindaoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    _scrollView.backgroundColor = [UIColor whiteColor];
    
    [[NSUserDefaults standardUserDefaults]setBool:NO forKey:@"nightstyle"];
    
    _scrollView.delegate = self;
    _scrollView.showsHorizontalScrollIndicator = NO;
    _scrollView.pagingEnabled = YES;
  
    _scrollView.contentSize = CGSizeMake(self.view.bounds.size.width*4,0);
    [self.view addSubview: _scrollView];
    self.pageControl = [[UIPageControl alloc]initWithFrame:CGRectMake(20, self.view.bounds.size.height*0.92, self.view.bounds.size.width-40, 40)];
    
    self.pageControl.numberOfPages = 4;
    self.pageControl.pageIndicatorTintColor =  [UIColor colorWithRed:57/255.0 green:51/255.0 blue:49/255.0 alpha:1.0];
    [self.view addSubview:self.pageControl];
    
    
    
    
    UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
    imageview.image = [UIImage imageNamed:@"yindao1.png"];
    [_scrollView addSubview:imageview];
    
    
    
    UIImageView *imageview1 = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width, 0,self.view.bounds.size.width, self.view.bounds.size.height)];
    imageview1.image = [UIImage imageNamed:@"yindao2.png"];
    [_scrollView addSubview:imageview1];
  
    
    UIImageView *imageview2 = [[UIImageView alloc] initWithFrame:CGRectMake(2*self.view.bounds.size.width, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
    imageview2.image = [UIImage imageNamed:@"yindao4.png"];
    [_scrollView addSubview:imageview2];
   
    
    UIImageView *imageview3 = [[UIImageView alloc] initWithFrame:CGRectMake(3*self.view.bounds.size.width, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
    imageview3.image = [UIImage imageNamed:@"yindao3.png"];
    [_scrollView addSubview:imageview3];
    
    
    
    
    
    CGFloat a = self.view.bounds.size.width/375;
    CGFloat b = self.view.bounds.size.height/667;
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.alpha = 0.8;
    
    button.frame = CGRectMake(self.view.bounds.size.width *3 + 70*a, 542*b, 235*a, 42*b);
    [_scrollView addSubview:button];
    button.layer.borderWidth = 0.5f;
    button.layer.borderColor = [UIColor whiteColor].CGColor;
    button.backgroundColor = [UIColor colorWithRed:56/255.0 green:53/255.0 blue:58/255.0 alpha:1.0];
    [button setTitle:@"马上体验" forState:UIControlStateNormal];

    button.titleLabel.font = [UIFont boldSystemFontOfSize:20];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    
}
-(void)buttonAction:(UIButton *)btn
{
    
    
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    //参数1:事件标识
    //参数2:像接受通知的对象传一个值(对象)
    //参数3:系统使用这个参数发送一些值
    [center postNotificationName:@"换根视图" object:nil userInfo:nil];
    
    
    
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    self.pageControl.currentPage = (scrollView.contentOffset.x + 50)/ self.view.bounds.size.width;
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
